package com.oauth.global.client.ui.birthday;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.global.client.beans.BirthdayClientBean;

public class BirthdayMember extends Composite {

	private static BirthdayUiBinder uiBinder = GWT.create(BirthdayUiBinder.class);

	interface BirthdayUiBinder extends UiBinder<Widget, BirthdayMember> {
	}

	@UiField
	Image profileImage;

	@UiField
	Image appIconImage;

	@UiField
	Label birthday;

	@UiField
	Anchor name;

	private BirthdayClientBean mBirthdayClientBean;

	public BirthdayMember(BirthdayClientBean pBirthdayBean) {
		initWidget(uiBinder.createAndBindUi(this));
		mBirthdayClientBean = pBirthdayBean;
		profileImage.setUrl(pBirthdayBean.getPictureUrl());
		appIconImage.setUrl(pBirthdayBean.getAppIconUrl());
		name.setText(pBirthdayBean.getName());
		birthday.setText(pBirthdayBean.getBirthday());
	}

	@UiHandler("name")
	public void onNameClick(ClickEvent e) {
		Window.open(mBirthdayClientBean.getProfileUrl(), name.getText(), null);
	}

}
